﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Silverlight4ApplicationDemo
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e) {
            var service = new Silverlight4ApplicationDemo.ServiceReference.DataServiceDemoClient( );
            service.GetMockDataCompleted += new EventHandler<ServiceReference.GetMockDataCompletedEventArgs>(service_GetMockDataCompleted);
            service.GetMockData2Completed += (s, args) => {
                var data = args.Result;
                this.LayoutRoot.DataContext = data;
                //this.DataTable.ItemsSource = data.DataList;
            };
            service.GetMockDataAsync(10);
            //service.GetMockData2Async( );
        }

        void service_GetMockDataCompleted(object sender, ServiceReference.GetMockDataCompletedEventArgs e) {
            try {
                var data = e.Result;
                this.LayoutRoot.DataContext = data;
                this.DataTable.ItemsSource = data.DataList;
            } catch {
                throw;
            }
            //
        }

      
    }
}
